package com.getui.java.query;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Map;

import com.getui.java.COMM;
import com.gexin.rp.sdk.base.IQueryResult;
import com.gexin.rp.sdk.http.IGtPush;

public class GetOnlineUserTest {

	public static void testGetOnlineUser() {
		IGtPush push = new IGtPush(COMM.appKey, COMM.masterSecret);
		IQueryResult queryResult = push.getLast24HoursOnlineUserStatistics(COMM.appId);
		System.out.println(queryResult.getResponse());
		System.out.println(queryResult.getResponse().get("appId"));
		System.out.println(queryResult.getResponse().get("onlineStatics"));

		Map data = (Map) queryResult.getResponse().get("onlineStatics");
		Iterator<Map.Entry> it = data.entrySet().iterator();
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		while (it.hasNext()) {
			Map.Entry entry = it.next();
			Long key = Long.valueOf(entry.getKey().toString());
			Integer value = Integer.valueOf(entry.getValue().toString());
			Date date = new Date();
			date.setTime(key);
			System.out.println(sdf.format(date) + "=" + value);
		}
	}

	public static void main(String[] args) {
		testGetOnlineUser();
	}
}